package net.zoneland.knowledge.dao;

import java.util.List;
import net.zoneland.knowledge.model.QaSuggest;
import net.zoneland.knowledge.model.QaSuggestExample;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface QaSuggestMapper {
    @SelectProvider(type=QaSuggestSqlProvider.class, method="countByExample")
    long countByExample(QaSuggestExample example);

    @Delete({
        "delete from AITK_QA_SUGGEST",
        "where ID = #{id,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String id);

    @Insert({
        "insert into AITK_QA_SUGGEST (ID, QUESTIONTYPE, ",
        "TITLE, CONTENTS, ",
        "REQID, REQNAME, ",
        "CMPNAME, DEPTDN, ",
        "CREATETIME)",
        "values (#{id,jdbcType=VARCHAR}, #{questionType,jdbcType=VARCHAR}, ",
        "#{title,jdbcType=VARCHAR}, #{contents,jdbcType=VARCHAR}, ",
        "#{reqId,jdbcType=VARCHAR}, #{reqName,jdbcType=VARCHAR}, ",
        "#{cmpName,jdbcType=VARCHAR}, #{deptDn,jdbcType=VARCHAR}, ",
        "#{createTime,jdbcType=TIMESTAMP})"
    })
    int insert(QaSuggest record);

    @InsertProvider(type=QaSuggestSqlProvider.class, method="insertSelective")
    int insertSelective(QaSuggest record);

    @SelectProvider(type=QaSuggestSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="ID", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="QUESTIONTYPE", property="questionType", jdbcType=JdbcType.VARCHAR),
        @Result(column="TITLE", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="CONTENTS", property="contents", jdbcType=JdbcType.VARCHAR),
        @Result(column="REQID", property="reqId", jdbcType=JdbcType.VARCHAR),
        @Result(column="REQNAME", property="reqName", jdbcType=JdbcType.VARCHAR),
        @Result(column="CMPNAME", property="cmpName", jdbcType=JdbcType.VARCHAR),
        @Result(column="DEPTDN", property="deptDn", jdbcType=JdbcType.VARCHAR),
        @Result(column="CREATETIME", property="createTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<QaSuggest> selectByExample(QaSuggestExample example);

    @Select({
        "select",
        "ID, QUESTIONTYPE, TITLE, CONTENTS, REQID, REQNAME, CMPNAME, DEPTDN, CREATETIME",
        "from AITK_QA_SUGGEST",
        "where ID = #{id,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="ID", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="QUESTIONTYPE", property="questionType", jdbcType=JdbcType.VARCHAR),
        @Result(column="TITLE", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="CONTENTS", property="contents", jdbcType=JdbcType.VARCHAR),
        @Result(column="REQID", property="reqId", jdbcType=JdbcType.VARCHAR),
        @Result(column="REQNAME", property="reqName", jdbcType=JdbcType.VARCHAR),
        @Result(column="CMPNAME", property="cmpName", jdbcType=JdbcType.VARCHAR),
        @Result(column="DEPTDN", property="deptDn", jdbcType=JdbcType.VARCHAR),
        @Result(column="CREATETIME", property="createTime", jdbcType=JdbcType.TIMESTAMP)
    })
    QaSuggest selectByPrimaryKey(String id);

    @UpdateProvider(type=QaSuggestSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") QaSuggest record, @Param("example") QaSuggestExample example);

    @UpdateProvider(type=QaSuggestSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") QaSuggest record, @Param("example") QaSuggestExample example);

    @UpdateProvider(type=QaSuggestSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(QaSuggest record);

    @Update({
        "update AITK_QA_SUGGEST",
        "set QUESTIONTYPE = #{questionType,jdbcType=VARCHAR},",
          "TITLE = #{title,jdbcType=VARCHAR},",
          "CONTENTS = #{contents,jdbcType=VARCHAR},",
          "REQID = #{reqId,jdbcType=VARCHAR},",
          "REQNAME = #{reqName,jdbcType=VARCHAR},",
          "CMPNAME = #{cmpName,jdbcType=VARCHAR},",
          "DEPTDN = #{deptDn,jdbcType=VARCHAR},",
          "CREATETIME = #{createTime,jdbcType=TIMESTAMP}",
        "where ID = #{id,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(QaSuggest record);
}
